home *** CD-ROM | disk | FTP | other *** search
- on RandomizeAfterTwo
- global ReqPetStore, ReqMovies, ReqGrocery, ReqDrugstore, ReqDrycleaners, ReqFarm, ReqZoo, ReqGrandma, ReqSchool, ReqPark, ReqPolice, ReqAirport, RewPetStore, RewMovies, RewGrocery, RewDrugStore, RewDryCleaners, RewFarm, RewZoo, RewGrandMa, RewSchool, RewPark, RewPolice, RewAirport, LocRew, LocReq, Locations, rewardLocs, requestLocs, AvailableLocRew, AvailableLocReq, NewCity, Loc1Name, Loc2Name, loc1Rew, Loc2Rew, HIDELOC, dummyList, availableLocs, calculatedLocs
- if not calculatedLocs then
- set HIGHLINKLOC to EMPTY
- set HIDELOC to EMPTY
- set highlink to 0
- set calculatedLocs to 1
- set AvailableLocRew to LocRew
- set AvailableLocReq to LocReq
- set NewCity to []
- set rewardLocs to []
- set requestLocs to []
- set G to 0
- repeat with d = 1 to 3
- set escapecounter to 0
- set G to G + 1
- if d = 3 then
- set tempcount to count(availableLocs)
- set rnum to random(tempcount)
- set RandLoc to getAt(availableLocs, rnum)
- else
- if d = 1 then
- set rnum to getOne(availableLocs, Loc1Name)
- set RandLoc to getAt(availableLocs, rnum)
- set RandRew to loc1Rew
- else
- if d = 2 then
- set rnum to getOne(availableLocs, Loc2Name)
- set RandLoc to getAt(availableLocs, rnum)
- set RandRew to Loc2Rew
- end if
- end if
- end if
- deleteAt(availableLocs, rnum)
- setAt(NewCity, G, RandLoc)
- set RewardList to getAt(AvailableLocRew, rnum)
- set RequestList to getAt(AvailableLocReq, rnum)
- deleteAt(AvailableLocRew, rnum)
- deleteAt(AvailableLocReq, rnum)
- if d = 3 then
- set valid to 0
- repeat while not valid
- set tempcount to count(RewardList)
- set rnum to random(tempcount)
- set RandRew to getAt(RewardList, rnum)
- set good to 1
- repeat with W = 1 to count(rewardLocs)
- if getAt(rewardLocs, W) = RandRew then
- set good to 0
- end if
- end repeat
- if good then
- set valid to 1
- end if
- end repeat
- end if
- setAt(rewardLocs, G, RandRew)
- setAt(requestLocs, G, EMPTY)
- repeat with y = 1 to 2
- set G to G + 1
- set LinkFound to 0
- repeat while not LinkFound
- set tempcount to count(availableLocs)
- set rnum to random(tempcount)
- set RandLoc to getAt(availableLocs, rnum)
- set RewardList to getAt(AvailableLocRew, rnum)
- set RequestList to getAt(AvailableLocReq, rnum)
- set escapecounter to escapecounter + 1
- set ListCount to count(RequestList)
- set keepLooking to 1
- repeat with T = 1 to ListCount
- if keepLooking then
- set tempReq to getAt(RequestList, T)
- if (tempReq = RandRew) or (escapecounter >= 40) then
- if ((d = 1) and (Loc2Name <> RandLoc)) or ((d = 2) and (Loc1Name <> RandLoc)) or (d = 3) then
- set LinkFound to 1
- setAt(NewCity, G, RandLoc)
- set rchange to 0
- if y >= highlink then
- set highlink to y
- set tempnLoc to HIDELOC
- set HIDELOC to RandLoc
- set rchange to 1
- end if
- setAt(requestLocs, G, tempReq)
- if escapecounter >= 40 then
- if rchange then
- set highlink to highlink - 1
- set HIDELOC to tempnLoc
- end if
- setAt(requestLocs, G, EMPTY)
- end if
- set tempcount to count(RewardList)
- set valid to 0
- repeat while valid = 0
- set newnum to random(tempcount)
- set RandRew to getAt(RewardList, newnum)
- if RandRew <> tempReq then
- set valid to 1
- setAt(rewardLocs, G, RandRew)
- set keepLooking to 0
- deleteAt(availableLocs, rnum)
- deleteAt(AvailableLocRew, rnum)
- deleteAt(AvailableLocReq, rnum)
- end if
- end repeat
- end if
- end if
- end if
- end repeat
- end repeat
- end repeat
- end repeat
- set ACount to count(availableLocs)
- repeat with T = 1 to ACount
- set G to G + 1
- set tempcount to count(availableLocs)
- set rnum to random(tempcount)
- set RandLoc to getAt(availableLocs, rnum)
- deleteAt(availableLocs, rnum)
- setAt(NewCity, G, RandLoc)
- set RewardList to getAt(AvailableLocRew, rnum)
- set RequestList to getAt(AvailableLocReq, rnum)
- deleteAt(AvailableLocRew, rnum)
- deleteAt(AvailableLocReq, rnum)
- set tempcount to count(RewardList)
- set cnt2 to 0
- set notGood to 1
- repeat while notGood
- set cnt2 to cnt2 + 1
- set rnum to random(tempcount)
- set RandRew to getAt(RewardList, rnum)
- set rewCount to 1
- repeat with Z = 1 to count(rewardLocs)
- set curRew to getAt(rewardLocs, Z)
- if curRew = RandRew then
- set rewCount to rewCount + 1
- end if
- end repeat
- if (rewCount <= 2) and (cnt2 >= 20) then
- setAt(rewardLocs, G, RandRew)
- setAt(requestLocs, G, EMPTY)
- set notGood to 0
- end if
- end repeat
- end repeat
- if HIDELOC = EMPTY then
- repeat with HH = 1 to count(NewCity)
- if getAt(NewCity, HH) <> EMPTY then
- set HIDELOC to getAt(NewCity, HH)
- end if
- end repeat
- end if
- set dummyList to ["money", "newsPaper", "donut", "popcorn", "kite", "pencil", "aspirin", "ticket", "butter", "copPaper", "apron", "overalls", "balloons", "socks", "strawberries", "corn", "lollyPop", "shirt", "goldFish", "leash", "hat", "thermometer", "hay"]
- repeat with T = 1 to count(requestLocs)
- set hold1 to getAt(requestLocs, T)
- if (hold1 <> EMPTY) and (hold1 <> " ") then
- set temp to getOne(dummyList, hold1)
- if temp <> 0 then
- deleteAt(dummyList, temp)
- end if
- end if
- end repeat
- end if
- set f to getOne(NewCity, Loc1Name)
- setAt(rewardLocs, f, EMPTY)
- set f to getOne(NewCity, Loc2Name)
- setAt(rewardLocs, f, EMPTY)
- end
-
- on showdata
- global requestLocs, rewardLocs, NewCity, HIDELOC
- put "rewardLocs = " & rewardLocs
- put "requestLocs = " & requestLocs
- put "newCity = " & NewCity
- put "hiding at " & HIDELOC
- end
-